﻿using System;
using System.Web;

namespace DigDes.DSchool.SUPS.Web.UI
{
    public class ImageHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            byte[] image = DigDes.DSchool.SUPS.DataAccess.Database.DataRdr_Cargo.LoadImage(Int32.Parse(context.Request.QueryString["Cargo_ID"]));
            context.Response.ContentType = "image/jpeg";
            if (image != null)
            {
                context.Response.BinaryWrite(image);
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("No image");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}